package com.gitee.feizns.explore.data_structure.tree.cus.ttt;

import com.gitee.feizns.explore.data_structure.tree.cus.Tree;

import java.util.Map;
import java.util.stream.Collectors;

/**
 * 二三树
 * @author feizns
 * @since 2019/11/27
 */
public interface Ttt<K extends Comparable<K>, V> extends Tree<K, V> {

    @Override
    default boolean isEmpty() {
        return size() == 0;
    }

    @Override
    default boolean containsKey(Object key) {
        return entrySet().stream().map(Entry::getKey).collect(Collectors.toSet()).contains(key);
    }

    @Override
    default boolean containsValue(Object value) {
        return entrySet().stream().map(Entry::getValue).collect(Collectors.toList()).contains(value);
    }

    @Override
    default void putAll(Map<? extends K, ? extends V> m) {
        m.forEach(this::put);
    }

}

